package com.js.study.datastructs.leetcode;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

/**
 * @Author JiangSen
 * @DATE 2023/12/28 15:12
 */
public class le1 {

    private int[] hash(int[] nums,int target){
        HashMap<Integer,Integer> hashMap = new HashMap<>();
        int length = nums.length;
        for (int i = 0; i < length; i++) {
            if(hashMap.containsKey(target - nums[i])){
                return new int[]{i,hashMap.get(target-nums[i])};
            }
            hashMap.put(nums[i],i);
        }
        return null;
    }
    private int[] twoSum(int[] nums,int target){
        int length = nums.length;
        int i = 1,j=0;
        while(i<length && j<length){
            if(nums[i]+nums[j] == target){
                return new int[]{i,j};
            }
            i++;
            if(i==length){
                j++;
                i=j+1;

            }
        }
        return new int[0];
    }
    public static void main(String[] args) {
        int[] nums ={2,5,5,11};
        le1 le1 = new le1();
        int[] ints = le1.twoSum(nums, 10);
        System.out.println(Arrays.toString(ints));
    }
}
